<template> 
 <ul class="news-list">
<news-item v-for="news in newsArray" :key="news.id" 
 :id="news.id" :title="news.title" 
 :content="news.content" @del="del"></news-item> 
 </ul> 
</template> 

<script> 
 // 导入子组件使用，@表示 src 目录 
 import NewsItem from '@/components/NewsItem.vue' 
 export default { 
 components: { 
 // 注册子组件 
 NewsItem, 
 }, 
 data() { 
 return { 
 newsArray: [ 
 { id: 1, title: '新闻标题 1', content: '新闻内容 1' }, 
 { id: 2, title: '新闻标题 2', content: '新闻内容 2' }, 
 { id: 3, title: '新闻标题 3', content: '新闻内容 3' }, 
 ], 
 } 
 }, 
 methods: { 
 del(id) { 
 // 删除指定 id 的新闻 
 const index = this.newsArray.findIndex((item) => item.id === id) 
 this.newsArray.splice(index, 1) 
 }, 
 }, 
 } 
 </script> 
 
 <style scoped> 
 .news-list { 
 list-style: none; 
 padding: 10px; 
 border: 1px solid blue; 
 } 
 </style> 